#!/usr/bin/bash

ARG_NAME=pkgsrc_base
if /usr/sbin/mdata-get ${ARG_NAME} 1>/dev/null 2>&1; then
    ARG_VALUE=$(/usr/sbin/mdata-get ${ARG_NAME})
    ARG_VALUE=${ARG_VALUE%*/}
    gsed -i "s|^https://pkgsrc.smartos.org|${ARG_VALUE}|" /opt/local/etc/pkgin/repositories.conf 1>/dev/null 2>&1
    gsed -i "s|^PKG_PATH=https://pkgsrc.smartos.org|PKG_PATH=${ARG_VALUE}|" /opt/local/etc/pkg_install.conf    
fi  